
###############################################################################
# BASIC VARIABLES
###############################################################################

# name of the project
00_project:=$(strip $(project))
ifeq ($(00_project),)
00_project:=.dummy
endif

# cpu-os-comp
00_coc:=$(strip $(coc))
ifeq ($(00_coc),)
00_coc:=x86_linux_g++
endif

# major version
00_M_version:=$(strip $(M_version))
ifeq ($(00_M_version),)
00_M_version:=1
endif

# minor version
00_m_version:=$(strip $(m_version))
ifeq ($(00_m_version),)
00_m_version:=0
endif

# build number
00_build_number:=$(strip $(build_number))
ifeq ($(00_build_number),)
00_build_number=1
endif


# defining target
00_target:=$(strip $(target))

ifeq ($(00_target),)
00_target=debug
endif

ifneq ($(00_target),debug)
ifneq ($(00_target),target)
00_target=debug
endif
endif



# cpu
00_cpu:=$(shell echo $(00_coc) | cut -d '_' -f 1)

# os 
00_os:=$(shell echo $(00_coc) | cut -d '_' -f 2)

# compiler
00_comp:=$(shell echo $(00_coc) | cut -d '_' -f 3)

# if 'verbose' is not defined, the first action of the rule (command) is 
# '@echo', which will make the identifier 'echo' not to appear on the 
# terminal, as well as all the bash commands used
00_verbose:=$(strip $(verbose))
ifeq ($(00_verbose),1)
00_show:=echo
# if 'verbose' is defined the make cmd is this way
00_make_cmd=make project="$(00_project)" coc="$(00_coc)" target="$(00_target)" verbose="$(00_verbose)" M_version="$(00_M_version)" m_version="$(00_m_version)" build_number="$(00_build_number)"
else
00_show:=@echo
# if 'verbose' is not defined the make cmd is this way
00_make_cmd=make -s project="$(00_project)" coc="$(00_coc)" target="$(00_target)" verbose="$(00_verbose)" M_version="$(00_M_version)" m_version="$(00_m_version)" build_number="$(00_build_number)"
endif

###############################################################################
# DIRECTORIES
###############################################################################
# directory of the tool used to build the projects
00_dir_tool=$(builder_dir)
ifeq ($(00_dir_tool),)
00_dir_tool=$(PWD)
endif

# base directory of tenacitas
00_dir_tenacitas=$(subst /dev/cpp/builder/tenacitas,,$(00_dir_tool))

# ------------------------------------------------------------------------------
# products directories

# production programs files directory
00_dir_product_bin=$(00_dir_tenacitas)/bin

# production library files directory
00_dir_product_lib=$(00_dir_tenacitas)/lib

# production project configuration files directory
00_dir_product_cfg=$(00_dir_tenacitas)/cfg/$(00_project)

# production project documentation files directory
00_dir_product_doc=$(00_dir_tenacitas)/doc/$(00_project)

# production project input files directory
00_dir_product_input=$(00_dir_tenacitas)/input/$(00_project)

# production project output files directory
00_dir_product_output=$(00_dir_tenacitas)/output/$(00_project)

# production project temporary files directory
00_dir_product_tmp=$(00_dir_tenacitas)/tmp/$(00_project)

# production project log files directory
00_dir_product_log=$(00_dir_tenacitas)/log/$(00_project)

# ------------------------------------------------------------------------------
# development directories

# development base directory
00_dir_dev=$(00_dir_tenacitas)/dev

# c++ code development base directory
00_dir_dev_codes=$(00_dir_dev)/cpp/code

# c++ project development base directory
00_dir_dev_prjs=$(00_dir_dev)/cpp//prj/tenacitas

# c++ project development directory
00_dir_dev_prj=$(00_dir_dev_prjs)/$(00_project)

# c++ development code base directory
00_dir_dev_code=$(00_dir_dev_codes)/$(00_project)

# project directories for source files
00_dir_dev_src=$(00_dir_dev_code)/src

# base directory for object files
00_dir_dev_obj:=$(00_dir_dev_code)/obj

# project directories for header files
00_dir_dev_inc:=$(00_dir_dev_codes)

# project directories for documentation files
00_dir_dev_doc:=$(00_dir_dev_code)/doc

# project directories for input files
00_dir_dev_input:=$(00_dir_dev_code)/input

# project directories for configuration files
00_dir_dev_cfg:=$(00_dir_dev_code)/cfg

# project directories for output files
#dir_dev_output:=$(00_dir_dev_code)/output

# project directory for test files
00_dir_dev_test:=$(00_dir_dev_code)/test

# base directory for log files
#dir_dev_log=$(00_dir_dev_code)/log

# base directory for tmp files
#dir_dev_tmp=$(00_dir_dev_code)/tmp

###############################################################################
# CPU, OS AND COMPILER
###############################################################################

# accessing the definitions for the cpu-os-comp combination
-include $(00_dir_tool)/cpu_os_comp/$(00_cpu)_$(00_os)_$(00_comp).mk

###############################################################################
# TYPES OF PROJECT
###############################################################################

# identifiers of the possible types of project
00_library_prj_type=lib
00_program_prj_type=pgm
00_just_copy_prj_type=just_copy
00_module_prj_type=mod

###############################################################################
# PROJECT DEFINITIONS
###############################################################################

# accessing the definitions for this project
-include $(00_dir_dev_prj)/project.mk


###############################################################################
# MISCELANEOUS
###############################################################################

# this is for the 'make cmd_info cmd=<cmd>' command
# if no <cmd> is defined, we suggest 'prj_info'
00_cmd:=$(strip $(cmd))
ifeq ($(00_cmd),)
00_cmd="prj_info"
endif

# right margin for output messages
00_line_formater=fmt -w 80 -u -s


###############################################################################
# BASIC RULES
###############################################################################

# Shows the basic commands (rules) 
default:
	$(00_show) ""                                                           ; \
	echo "------------------------------------------------------------"  ; \
	echo "Bacic commands:"                                               ; \
	echo "------------------------------------------------------------"  ; \
	echo ""                                                              ; \
	option="    make tutorial: shows a tutorial how to use the 'tenacitas' build system." ; \
	echo $$option | $(00_line_formater)                                     ; \
	echo ""                                                              ; \
	option="    make cmd_list: lists all the available commands with a brief explanation." ; \
	echo $$option | $(00_line_formater)                                     ; \
	echo ""                                                              ; \
	option="    make cmd_info cmd=<cmd_name>: shows detailed information for a command." ; \
	echo $$option | $(00_line_formater)                                     ; \
	echo ""                                                              ; \
	option="    make coc_list: lists the values of the variables for a CPU, OS, compiler combination" ; \
	echo $$option | $(00_line_formater)                                     ; \
	echo ""                                                              ; \
	option="    make prj_list: lists all the available Projects."         ; \
	echo $$option | $(00_line_formater)                                     ; \
	echo ""                                                              ; \


# Shows a tutorial that explains how the 'tenacitas' build system works 
tutorial:
	$(00_show) ""                                                          ; \
	echo "Please open $(00_dir_tool)/manual.pdf"                           ;



#-include mk/*.mk
